<script src="@{'/public/javascripts/advancedSearch.js'}" type="text/javascript" charset="${_response_encoding}"></script>
<div class="crudField crud_enum">
	<label for="object_subbase">
	    Subbase
	</label>
	<select id="object_subbase" name="subbase">
		#{list items:_subbases, as:'subbase'}	
			<option name="${subbase.id}" value="${subbase.id}">${subbase.nombre}</option>
	    #{/list}
	</select>
	<div class="condicionalSI"><a href="#" onclick="agregarCondicion(&quot;subbase&quot;, &quot;SI&quot;);">SI</a></div>
	<div class="condicionalNO"><a href="#" onclick="agregarCondicion(&quot;subbase&quot;, &quot;NO&quot;);">NO</a></div>
</div>
%{
    if(_object) {
        currentObject = _object
        currentType = _('controllers.CRUD$ObjectType').forClass(_object.getClass().getName())
    } else if(_class) {
        currentObject = null;
        currentType = _('controllers.CRUD$ObjectType').forClass(_class)
    } else {
        currentObject = _caller.object
        currentType = _caller.type
    }

    // Eval fields tags
    def fieldsHandler = [:]
    if(_body) {
        _body.setProperty('fieldsHandler', fieldsHandler);
        _body.toString(); // we skeep the real result ...
    }
}%

#{list items:_fields ?: currentType.fields*.name, as:'fieldName'}

    %{
        am = ''
    }%

    %{ def field = currentType.getField(fieldName) }%

<div class="crudField crud_${field.type}">

    %{ if(fieldsHandler[fieldName]) { }%
        %{
            def handler = fieldsHandler[fieldName]
            handler.setProperty('fieldName', 'object.' + field?.name + (field?.type == 'relation' ? '.' + currentType.keyName : ''))
            def oldObject = handler.getProperty('object')
            handler.setProperty('object', currentObject)
            out.println(handler.toString())
            handler.setProperty('object', oldObject)
            handler.setProperty('fieldName', null)
        }%
    %{ } else { }%

        #{ifnot field}
            %{ throw new play.exceptions.TagInternalException('Field not found -> ' + fieldName) }%
        #{/ifnot}

        #{if field.type == 'text'}
            #{crud.textField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
        #{/if}

        #{if field.type == 'password'}
            #{crud.passwordField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
        #{/if}

        #{if field.type == 'binary'}
            #{crud.fileField name:field.name, value:(currentObject ? currentObject[field.name] : null), id:currentObject?.id /}
        #{/if}

        #{if field.type == 'longtext'}
            #{crud.longtextField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
        #{/if}

        #{if field.type == 'number'}
            #{crud.numberField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
            %{ am = 'crud.help.numeric' }%
        #{/if}

        #{if field.type == 'date'}
            #{crud.dateField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
            %{ am = messages.get('crud.help.dateformat',play.libs.I18N.getDateFormat()) }%
        #{/if}

        #{if field.type == 'relation'}
            #{crud.relationField name:field.name, value:(currentObject ? currentObject[field.name] : null), field:field /}
        #{/if}

        #{if field.type == 'boolean'}
            #{if field.name == 'iscliente'}
				Cliente
			#{/if}
            #{if field.name == 'isproveedor'}
				Proveedor
			#{/if}
			#{if field.name == 'ismedio'}
				Medio
			#{/if}
			#{if field.name == 'isintermediario'}
				Intermediario
			#{/if}
			#{if field.name == 'isotro'}
				Otro
			#{/if}
        #{/if}

        #{if field.type == 'enum'}
            #{crud.enumField name:field.name, value:(currentObject ? currentObject[field.name] : null), property:field /}
        #{/if}

        #{if field.type == 'hidden'}
            #{crud.hiddenField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
        #{/if}
 	%{ } }%
 	
 	#{if field.name != 'lastLogs' && field.name != 'arcadianos' && field.name != 'intermediario'}
		<div class="condicionalSI"><a href="#" onclick='agregarCondicion("${field.name}", "SI");'>SI</a></div>
		<div class="condicionalNO"><a href="#" onclick='agregarCondicion("${field.name}", "NO");'>NO</a></div>
	#{/if}
   
</div>

#{/list}

<script type="text/javascript">


</script>